package com.p2p.base.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.p2p.base.model.BackendUser;

public interface BackendUserDao extends BaseMapper{

	@Select("select id,email,is_enabled as isEnabled,login_name as loginName,memo,password,phone,user_name as userName,version,create_time as createTime from p2p_back_user where login_name=#{loginName} and is_enabled=true")
	BackendUser findByLoginName(String loginName);
	
	/*@Select("select p.acl,p.name,p.url,p.parent_acl as parentAcl,"
			+ "p.privilege_level, p.sort_no from  p2p_user_role ur,"
			+ "p2p_role_privilege rp,p2p_privilege p "
			+ "where ur.role_id = rp.role_id and rp.privilege_acl = p.acl and ur.user_id = #{userId} order by p.parent_acl,p.sort_no")
	List<Map<String,String>> findPrivilegeByUserId(Long userId);*/
	
	@Select("select p.enname from  p2p_user_role ur,"
			+ "p2p_role_privilege rp,p2p_privilege p "
			+ "where ur.role_id = rp.role_id and rp.privilege_acl = p.acl and ur.user_id = #{userId} order by p.parent_acl,p.sort_no")
	List<String> findPrivilegeByUserId(Long userId);

}
